import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true, name: 'login' },
  { path: '/404', component: () => import('@/views/404'), hidden: true, name: '404' },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/productManage',
    component: Layout,
    redirect: '/productManage/index',
    name: '轮播图管理',
    alwaysShow: true,
    hidden: false,
    meta: { title: '轮播图管理', icon: 'pic' },
    children: [
      {
        path: 'addCarousel',
        name: '新增轮播图',
        hidden: false,
        component: () => import('@/views/productManage/addCarousel'),
        meta: { title: '新增轮播图', icon: 'add' }
      },
      {
        path: 'carouselList',
        name: '轮播图管理',
        component: () => import('@/views/productManage/carouselList'),
        meta: { title: '轮播图管理', icon: 'pic' }
      }
    ]
  },
  {
    path: '/signUp',
    component: Layout,
    // redirect: '/signUp/list',
    name: '报名管理',
    alwaysShow: true,
    hidden: false,
    meta: { title: '报名管理', icon: 'signUp', keepAlive: true },
    children: [
      {
        path: 'signUp/list',
        name: '报名管理',
        hidden: false,
        component: () => import('@/views/signUp/list'),
        meta: { title: '报名管理', icon: 'signUp', keepAlive: true }
      },
      {
        path: 'signUp/add',
        name: '新增报名',
        hidden: true,
        component: () => import('@/views/signUp/add'),
        meta: { title: '', icon: 'add', keepAlive: true }
      },
      {
        path: 'signUp/award',
        name: '颁奖',
        hidden: true,
        component: () => import('@/views/signUp/award'),
        meta: { title: '颁奖', icon: 'linePManage', keepAlive: true }
      },
      {
        path: 'signUp/registryInfo',
        name: '查看报名情况',
        component: () => import('@/views/signUp/registryInfo'),
        meta: { title: '查看报名情况', icon: 'check' }
      }
    ]
  },
  {
    path: '/activity',
    component: Layout,
    name: '活动管理',
    alwaysShow: true,
    meta: { title: '活动管理', icon: 'flag' },
    children: [
      {
        path: '/activity/list',
        component: () => import('@/views/activity/list'),
        name: '征集活动管理',
        meta: { title: '征集活动管理', icon: 'collect' }
      },
      {
        path: '/activity/add',
        component: () => import('@/views/activity/add'),
        name: '新增活动',
        hidden: true,
        meta: { title: '', icon: 'member' }
      },
      {
        path: '/activity/activityInfo',
        component: () => import('@/views/activity/activityInfo'),
        name: '查看活动征集情况',
        meta: { title: '查看活动征集情况', icon: 'check' }
      },
      {
        path: '/activity/activityInfoDetail',
        component: () => import('@/views/activity/activityInfoDetail'),
        name: '活动征集情况详情',
        hidden: true,
        meta: { title: '活动征集情况详情', icon: 'member' }
      },
      {
        path: '/activity/award',
        component: () => import('@/views/activity/award'),
        name: '颁奖',
        hidden: true,
        meta: { title: '颁奖', icon: 'member' }
      }
    ]
  },
  {
    path: '/webSite',
    component: Layout,
    name: '官网简介',
    alwaysShow: true,
    meta: { title: '官网简介', icon: 'website' },
    children: [
      {
        path: '/webSite/aerospace',
        component: () => import('@/views/webSite/aerospace'),
        name: '中国宇航学会',
        meta: { title: '中国宇航学会', icon: 'spaceflight' }
      },
      {
        path: '/webSite/researchCenters',
        component: () => import('@/views/webSite/researchCenters'),
        name: '中国科协青少年科技中心',
        meta: { title: '中国科协青少年科技中心', icon: 'science' }
      }
    ]
  },
  {
    path: '/product',
    component: Layout,
    name: '课程管理',
    alwaysShow: true,
    meta: { title: '课程管理', icon: 'course' },
    children: [
      {
        path: '/product/sourseManage',
        component: () => import('@/views/product/sourseManage'),
        name: '课程管理',
        hidden: false,
        meta: { title: '课程管理', icon: 'course' }
      },
      {
        path: '/product/add',
        component: () => import('@/views/product/add'),
        name: '新增课程',
        hidden: true,
        meta: { title: '新增课程', icon: 'member' }
      },
      {
        path: '/product/detail',
        component: () => import('@/views/product/detail'),
        name: '详情',
        hidden: true,
        meta: { title: '详情', icon: 'member' }
      },
      {
        path: '/product/award',
        component: () => import('@/views/product/award'),
        name: '颁奖',
        hidden: true,
        meta: { title: '颁奖', icon: 'member' }
      },
      {
        path: '/product/index',
        component: () => import('@/views/product/index'),
        name: '课程类别管理',
        meta: { title: '课程类别管理', icon: 'courseType' }
      },
      {
        path: '/product/upload',
        component: () => import('@/views/product/upload'),
        name: '上传试题',
        hidden: true,
        meta: { title: '上传试题', icon: 'member' }
      }
    ]
  },
  {
    path: '/prductWenc',
    component: Layout,
    name: '文创产品',
    alwaysShow: true,
    meta: { title: '文创产品', icon: 'prduct' },
    children: [
      {
        path: '/prductWenc/index',
        component: () => import('@/views/prductWenc/index'),
        name: '文创产品管理',
        hidden: false,
        meta: { title: '文创产品管理', icon: 'prduct' }
      },
      {
        path: '/prductWenc/add',
        component: () => import('@/views/prductWenc/add'),
        name: '新增',
        hidden: true,
        meta: { title: '', icon: 'password1' }
      }
    ]
  },
  {
    path: '/setting',
    component: Layout,
    name: '设置',
    alwaysShow: true,
    meta: { title: '设置', icon: 'setting' },
    children: [
      {
        path: '/setting/password',
        component: () => import('@/views/setting/password'),
        name: '修改密码',
        meta: { title: '修改密码', icon: 'password1' }
      }
    ]
  },
  {
    path: '/redirect',
    component: Layout,
    // redirect: '/',
    hidden: true,
    children: [{
      path: 'redirect',
      name: 'redirect',
      component: () => import('@/views/layout/components/Sidebar/redirect')
    }]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
